package com.yuntsg.nnsfcp.test.test;

import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;
import com.aspose.words.Font;
import lombok.SneakyThrows;

import java.awt.*;

/**
 * @Author: gcr
 * @Date: 2023/11/22 11:15 （日期和时间）
 */
public class AsposeWord2 {
    @SneakyThrows
    public static void main(String[] args) {

//        if (!getLicense()) {
//            return;
//        }
        String path = "D:\\Users\\55419\\Desktop\\";
        String fromPath = path + "dsasd.doc";
        Document doc = new Document(fromPath);
//        Document doc = new Document();
        String text = doc.getText();
        System.out.println(text);

//        //测试文字输出带格式的
        DocumentBuilder builder = new DocumentBuilder(doc);
        // 移动到特定位置进行写入开始
        builder.moveToBookmark("cxjl");
        //设置写日前字体大小
        Font font = builder.getFont();
//
        // 字体大小
        font.setSize(19);
        // 字体名称
        font.setName("楷体");
        // 颜色
        font.setColor(Color.blue);
        // 字间距 0 代表无间距
        font.setSpacing(2);
//
//
//
        builder.writeln("我我我我我我我我我我我我我我我我我我我我我我");

//// Specify font formatting for the hyperlink.
//        builder.getFont().setColor(Color.BLACK);
//        builder.getFont().setUnderline(Underline.DOUBLE);
//// Insert the link.
//        builder.writeln("Aspose Website");
//// Revert to default formatting.
//        builder.getFont().clearFormatting();
//        builder.getFont().setUnderline(Underline.length);
//// Insert the link.
//        builder.writeln("Aspose Website");
//// Revert to default formatting.
//        builder.getFont().clearFormatting();
//        builder.getFont().setUnderline(Underline.SINGLE);
//// Insert the link.
//        builder.writeln("Aspose Website");
//// Revert to default formatting.
//        builder.getFont().clearFormatting();
//        builder.getFont().setUnderline(Underline.DASH);
//// Insert the link.
//        builder.writeln("Aspose Website");
//// Revert to default formatting.
//        builder.getFont().clearFormatting();
//        builder.getFont().setUnderline(Underline.DASH_HEAVY);
//// Insert the link.
//        builder.writeln("Aspose Website");
//// Revert to default formatting.
//        builder.getFont().clearFormatting();
//        builder.getFont().setUnderline(Underline.DASH_LONG);
//// Insert the link.
//        builder.writeln("Aspose Website");
//// Revert to default formatting.
//        builder.getFont().clearFormatting();
//        builder.getFont().setUnderline(Underline.DASH_LONG_HEAVY);
//// Insert the link.
//        builder.writeln("Aspose Website");
//// Revert to default formatting.
//        builder.getFont().clearFormatting();
//        builder.getFont().setUnderline(Underline.WAVY_HEAVY);
//// Insert the link.
//        builder.writeln("Aspose Website");
//// Revert to default formatting.
//        builder.getFont().clearFormatting();
//        builder.writeln(" for more information.");
        long l = System.currentTimeMillis();

        doc.save(path + l + ".doc");
    }
}
